﻿; (function () {
    Highcharts.theme = {
        colors: ["#7cb5ec", "#f7a35c", "#90ee7e", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
           "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
        chart: {
            backgroundColor: null,
            style: {
                fontFamily: "Dosis, sans-serif"
            }
        },
        title: {
            style: {
                fontSize: '16px',
                fontWeight: 'bold',
                textTransform: 'uppercase'
            }
        },
        tooltip: {
            borderWidth: 0,
            backgroundColor: 'rgba(219,219,216,0.8)',
            shadow: false
        },
        legend: {
            itemStyle: {
                fontWeight: 'bold',
                fontSize: '13px'
            }
        },
        xAxis: {
            gridLineWidth: 1,
            labels: {
                style: {
                    fontSize: '12px'
                }
            }
        },
        yAxis: {
            minorTickInterval: 'auto',
            title: {
                style: {
                    textTransform: 'uppercase'
                }
            },
            labels: {
                style: {
                    fontSize: '12px'
                }
            }
        },
        plotOptions: {
            candlestick: {
                lineColor: '#404048'
            }
        },


        // General
        background2: '#F0F0EA'

    };
    // Apply the theme
    Highcharts.setOptions(Highcharts.theme);

})();

; (function () {
    var exporter = window.BT || {}
    var pieDefaultOpt = {
        chart: {
            type: 'pie',
            options3d: {
                enabled: true,
                alpha: 60,
                beta: 0
            }
        },
        credits: {
            enabled: false
        },
        title: null,
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>',
            borderRadius: 10,
            backgroundColor: '#FFFFFF',
            shadow: true
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'bottom',
            floating: true,
            borderRadius: 5,
            backgroundColor: '#FFFFFF',
            shadow: false,
            x: -40,
            y: -20
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                depth: 35,
                dataLabels: {
                    enabled: false,
                    format: '<b>{point.name}({y})</b> {point.percentage:.1f} %'
                },
                showInLegend: true
            }
        },
        exporting: {
            enabled: false
        }

    }

    var lineDefaultOpt = {
        chart: {
            borderWidth: 0
        },
        title: {
            text:'',
            x: -20 //center
        },
        xAxis: {
            categories: []
        },
        yAxis: {
            title: {
                text: '单位 (件)'
            },
            tickInterval: 200,
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        credits: {
            enabled: false
        },
        tooltip: {
            valueSuffix: '件',
            borderRadius: 10,
            backgroundColor: '#FFFFFF',
            shadow: true
        },
        legend: {
            enabled: true
        },
        series:[]
    }


    var barDefaultOpt = {
        chart: {
            borderWidth: 0,
            type: 'column'
        },
        title: {
            text: '',
            x: -20 //center
        },
        xAxis: {
            categories: []
        },
        yAxis: {
            title: {
                text: '单位 (件)'
            },
            tickInterval: 200,
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        credits: {
            enabled: false
        },
        tooltip: {
            valueSuffix: '件',
            borderRadius: 10,
            backgroundColor: '#FFFFFF',
            shadow: true
        },
        legend: {
            enabled: true
        },
        series: []
    };

    var barPercentDefault = {
        chart: {
            type: 'column'
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [],
            crosshair: true
        },
        yAxis: {
            min: 0,
            title: {
                text: '单位 (件)'
            },
            stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y} 件</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        //tooltip: {
        //    headerFormat: '<table>',
        //    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
        //        '<td style="padding:0"><b>{point.y}</b></td></tr>',
        //    footerFormat: '</table>',
        //    shared: true,
        //    useHTML: true
        //},
        plotOptions: {
            column: {
                stacking: 'normal'
            }
        },
        series: []
    };

    exporter.chart = {};

    //饼图
    exporter.chart.pie = function (jq, option) {
        var opt = $.extend({}, pieDefaultOpt, option);
        return jq.highcharts(opt);
    }

    //数量统计的折现图(概况 历年专利总量，历年有效专利量)
    exporter.chart.line = function (jq, title, option) {
        var opt = $.extend({}, lineDefaultOpt, option);
        opt.title.text = title;
        return jq.highcharts(opt);
    }
    exporter.chart.bar = function (jq, title,option) {

        var opt = $.extend({}, barDefaultOpt, option);
        opt.title.text = title;
        return jq.highcharts(opt);
    }
    exporter.chart.percentBar = function (jq, title,option) {
        var opt = $.extend({}, barPercentDefault, option);
        opt.title.text = title;
        return jq.highcharts(opt);
    }


    window.BT = exporter;
})();





